package com.kyh.sys.entity;

import java.util.Date;

import javax.persistence.Table;

import com.alibaba.fastjson.JSONObject;
import com.kyh.annotation.Model;
import com.kyh.entity.base.BaseEntity;

/**
*/
@Table(name="sys_button", catalog="button_id")
public class Button extends BaseEntity<Button> {

	@Model(nameTable="buttonId")
	private Long buttonId; // 主键ID
	@Model(nameTable="menuId")
	private Long menuId; // 所属菜单ID
	@Model(nameTable="buttonName")
	private String buttonName; // 按钮名称
	@Model(nameTable="buttonAttr")
	private String buttonAttr; // 按钮属性
	@Model(nameTable="buttonDiy")
	private String buttonDiy; // 按钮自定义路径
	@Model(nameTable="scripts")
	private String scripts; // 按钮自定义脚本
	@Model(nameTable="status")
	private Integer status; // 
	@Model(nameTable="createTime",type=Model.TYPE.DATE, format="yyyy-MM-dd HH:mm:ss")
	private Date createTime; // 
	@Model(nameTable="updateTime",type=Model.TYPE.DATE, format="yyyy-MM-dd HH:mm:ss")
	private Date updateTime; // 

	public Long getButtonId() {
		return buttonId;
	}
	public Button setButtonId(Long buttonId) {
		this.buttonId = buttonId;
		return this;
	}
	public Long getMenuId() {
		return menuId;
	}
	public Button setMenuId(Long menuId) {
		this.menuId = menuId;
		return this;
	}
	public String getButtonName() {
		return buttonName;
	}
	public Button setButtonName(String buttonName) {
		this.buttonName = buttonName;
		return this;
	}
	public String getButtonAttr() {
		return buttonAttr;
	}
	public Button setButtonAttr(String buttonAttr) {
		this.buttonAttr = buttonAttr;
		return this;
	}
	public String getButtonDiy() {
		return buttonDiy;
	}
	public Button setButtonDiy(String buttonDiy) {
		this.buttonDiy = buttonDiy;
		return this;
	}
	public String getScripts() {
		return scripts;
	}
	public Button setScripts(String scripts) {
		this.scripts = scripts;
		return this;
	}
	public Integer getStatus() {
		return status;
	}
	public Button setStatus(Integer status) {
		this.status = status;
		return this;
	}
	public Date getCreateTime() {
		return createTime;
	}
	public Button setCreateTime(Date createTime) {
		this.createTime = createTime;
		return this;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public Button setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
		return this;
	}

	public static Button button(
			Long menuId,
			String buttonName,
			String buttonAttr,
			String buttonDiy,
			Integer status
			) {
		Button entity = new Button();
		entity.setMenuId(menuId);
		entity.setButtonName(buttonName);
		entity.setButtonAttr(buttonAttr);
		entity.setButtonDiy(buttonDiy);
		entity.setStatus(status);
		return entity;
	}
	
	public JSONObject tree() {
		JSONObject JO = new JSONObject();
		
		JO.put("id", this.getButtonId());
		JO.put("text", this.getButtonName());
		JO.put("pid", this.getMenuId());
		JO.put("type", "button");
		return JO;
	}
}